<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>选择课程</title>
    <link rel="stylesheet" href="/static/css/bootstrap.min.css">
    <link rel="stylesheet" href="/static/css/dsb.css">
</head>
<body>

<nav class="navbar navbar-inverse navbar-fixed-top">
    <div class="container-fluid">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
                    aria-expanded="false" aria-controls="navbar">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand one-pan-link-mark" href="/logout/">退出登陆</a>
        </div>
    </div>
</nav>

<div class="container-fluid">
    <div class="row">
        <div class="col-sm-3 col-md-2 sidebar">
            <ul class="nav nav-sidebar">
                <li class=""><a href="/index" class="one-pan-link-mark">基本信息</a></li>
                <li class="active"><a href="/course" class="one-pan-link-mark">选课信息</a></li>
                <li class=""><a href="/mark" class="one-pan-link-mark">成绩信息</a></li>
                <li class=""><a href="/money" class="one-pan-link-mark">消费信息</a></li>
                <li class=""><a href="/book" class="one-pan-link-mark">图书借阅</a></li>
                <li class=""><a href="/course_manage" class="one-pan-link-mark">课程管理</a></li>
            </ul>
        </div>
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
            <h2 class="sub-header">选择课程</h2>
            
            {% if error_message %}
            <div class="alert alert-danger">
                {{ error_message }}
            </div>
            {% endif %}
            
            {% if success_message %}
            <div class="alert alert-success">
                {{ success_message }}
            </div>
            {% endif %}
            
            <div class="table-responsive">
                <form method="post" action="/select_course/">
                    <table class="table table-striped">
                        <thead>
                        <tr>
                            <th>选择</th>
                            <th>课程号</th>
                            <th>课程名</th>
                            <th>任课教师</th>
                            <th>状态</th>
                        </tr>
                        </thead>
                        <tbody>
                        {% if all_courses %}
                            {% for course in all_courses %}
                            <tr>
                                <td>
                                    <input type="radio" name="course_id" value="{{ course.co_num }}" 
                                           {% if course.co_num in selected_course_ids %}disabled{% endif %}>
                                </td>
                                <td>{{ course.co_num }}</td>
                                <td>{{ course.co_name }}</td>
                                <td>{{ course.co_teacher }}</td>
                                <td>
                                    {% if course.co_num in selected_course_ids %}
                                        <span class="label label-success">已选</span>
                                    {% else %}
                                        <span class="label label-default">未选</span>
                                    {% endif %}
                                </td>
                            </tr>
                            {% endfor %}
                        {% else %}
                            <tr>
                                <td colspan="5" class="text-center">暂无可选课程</td>
                            </tr>
                        {% endif %}
                        </tbody>
                    </table>
                    
                    <div class="form-group">
                        <button type="submit" class="btn btn-primary">确认选课</button>
                        <a href="/course/" class="btn btn-default">返回</a>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

</body>
</html> 